import { createRouter, createWebHistory } from "vue-router";
export const constantRoutes = [
  {
    path: "/",
    name: "首页",
    redirect: "/home",
    meta: {
      title: "首页",
      icon: "home",
    },
    hidden: true,
  },
  {
    path: "/home",
    name: "home",
    meta: {
      title: "首页",
      icon: "home",
    },
    component: () => import("@/views/home/index.vue"),
    hidden: true,
  },
  {
    path: "/enteralNutrition",
    name: "enteralNutrition",
    meta: {
      title: "肠内营养",
      icon: "enteralNutrition",
      customer: true,
    },
    component: () => import("@/views/enteralNutrition/enteralNutrition.vue"),
    hidden: true,
  },
  {
    path: "/educationList",
    name: "educationList",
    meta: {
      keepAlive: true,
      title: "宣教",
      icon: "educationList",
    },
    component: () => import("@/views/education/educationList.vue"),
    hidden: true,
  },

  {
    path: "/goodsManage",
    name: "goodsManage",
    meta: {
      title: "商品管理",
      icon: "goodsManage",
    },
    component: () => import("@/views/goods/goodsManage.vue"),
    hidden: true,
  },
  {
    path: "/historicalOrders",
    name: "historicalOrders",
    meta: {
      title: "历史订单",
      icon: "goodsManage",
    },
    component: () => import("@/views/order/historicalOrders.vue"),
    hidden: true,
  },
  {
    path: "/payment",
    name: "payment",
    meta: {
      title: "支付",
      icon: "payment",
    },
    component: () => import("@/views/payment/payment.vue"),
    hidden: true,
  },
  {
    path: "/education/educationDetails",
    name: "educationDetails",
    meta: {
      title: "健康咨询详情",
      icon: "educationDetails",
    },
    component: () => import("@/views/education/educationDetails.vue"),
    hidden: true,
  },
  {
    path: "/orderingDishes",
    name: "orderingDishes",
    meta: {
      title: "点餐",
      icon: "orderingDishes",
    },
    component: () => import("@/views/orderingDishes/orderingDishes.vue"),
    hidden: true,
  },
  {
    path: "/orderingList",
    name: "orderingList",
    meta: {
      title: "治疗膳食 ",
      icon: "orderingList",
      customer: true,
    },
    component: () => import("@/views/orderingDishes/orderingList.vue"),
    hidden: true,
  },
];

export const asyncRoutes = [
  // { path: "*", redirect: "/404", hidden: true }
];

const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes,
  // routes: constantRoutes.concat(asyncRoutesList)
});

router.beforeEach(async (to, from, next) => {
  // 动态添加浏览器title
  // window.document.title = "美亚健康 | " + to.meta.title;
  window.document.title = "湘雅医院西区锦茂食堂";
  next();
});

export default router;
